﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityFrameworkCore1
{
    public class BookConfig : IEntityTypeConfiguration<Book>
    {
        public void Configure(EntityTypeBuilder<Book> builder)
        {
            builder.ToTable("T_Books");
            builder.Property(b => b.Title).HasMaxLength(50).IsRequired();
            builder.Property(b => b.AuthorName).HasMaxLength(20).IsRequired();
            builder.Ignore(b => b.Age2);
            builder.Property(b => b.Name2).HasColumnName("Nametwo").HasColumnType("varchar(20)").HasMaxLength(30);
            builder.HasIndex(b => b.Title).IsUnique();
            builder.HasIndex(b => new { b.Name2, b.AuthorName });
        }
    }
}
